angular.module('starter.services', ['angularSoap', 'soapclient2'])

.factory('Chats', function() {
  // Might use a resource here that returns a JSON array

  // Some fake testing data
  var chats = [{
    id: 0,
    name: 'Ben Sparrow',
    lastText: 'You on your way?',
    face: 'img/ben.png'
  }, {
    id: 1,
    name: 'Max Lynx',
    lastText: 'Hey, it\'s me',
    face: 'img/max.png'
  }, {
    id: 2,
    name: 'Adam Bradleyson',
    lastText: 'I should buy a boat',
    face: 'img/adam.jpg'
  }, {
    id: 3,
    name: 'Perry Governor',
    lastText: 'Look at my mukluks!',
    face: 'img/perry.png'
  }, {
    id: 4,
    name: 'Mike Harrington',
    lastText: 'This is wicked good ice cream.',
    face: 'img/mike.png'
  }];

  return {
    all: function() {
      return chats;
    },
    remove: function(chat) {
      chats.splice(chats.indexOf(chat), 1);
    },
    get: function(chatId) {
      for (var i = 0; i < chats.length; i++) {
        if (chats[i].id === parseInt(chatId)) {
          return chats[i];
        }
      }
      return null;
    }
  };
});

app.service('MesService', ['$soap', '$http','$q', function ($soap, $http, $q) {

   // var webServiceURL = "http://www.holidaywebservice.com/HolidayService_v2/HolidayService2.asmx";
    // var webServiceURL = "http://localhost/Semis/AppService.asmx";
     var semisWebServiceURL = "http://172.20.254.22:8080/messervice/Semis/ClientDataService.asmx";
     var mcSysWebServiceURL = "http://172.20.254.22:8080/messervice/McSys/McSystem.asmx";
    return {
        HelloWorld: function () {
            return $soap.post(semisWebServiceURL, 'HelloWorld');
        },
        GetCountriesAvailable: function () {
            return $soap.post(semisWebServiceURL, 'GetSemisToolingInfo');
            },
        abc:function(){
            return [
            { id: 1, text: "111111", url: "img/ionic.png" }, { id: 2, text: "222222", url: "img/adam.jpg" }, { id: 3, text: "333333", url: "img/ben.png" },
            { id: 4, text: "444444", url: "img/max.png" }, { id: 5, text: "555555", url: "img/mike.png" }, { id: 6, text: "666666", url: "img/perry.png" },
            { id: 7, text: "777777", url: "img/ionic.png" }, { id: 8, text: "888888", url: "img/ionic.png" }, { id: 9, text: "999999", url: "img/ionic.png" },
            { id: 10, text: "aaaaaa", url: "img/ionic.png" }, { id: 11, text: "bbbbbb", url: "img/ionic.png" }, { id: 12, text: "cccccc", url: "img/ionic.png" },
            ];
        },
        Login:function(username,password){
           return  $soap.post(mcSysWebServiceURL,'UserLogin',{user: username, pwd: password});
        },
        GetUserCEMenuAction:function(userId){
          return $soap.post(mcSysWebServiceURL,'GetUserCEMenuAction',{userId:userId});

        }
  }
}])